//-----------------------------------------------------
// nguimanager.cpp
//-----------------------------------------------------

/**
 * @file nguimanager.cpp
 */

#include "nguimanager.h"
#include "guientity.h"
#include "staticguientity.h"
#include "application/ngfxobject.h"

namespace nebulaGUI {

	NGUIManager::NGUIManager(): _scene(0)/*, _player(0)*/ 
	{
	}

	NGUIManager::~NGUIManager()
	{
		//if (_entities)
		//	delete _entities;
	}

	void NGUIManager::staticEntityCreated(const logic::ILogicFacade *facade, logic::CEntity *logicEntity)
	{
		NGUIStaticEntity *staticEntity =  new NGUIStaticEntity();
		if (staticEntity->setResource("data/gfx/bullet.n2"))
		{
			staticEntity->loadResource();
			staticEntity->setLogicEntity(logicEntity);
			_entities.push_back(staticEntity);

		}
	}

	bool NGUIManager::initScene(const char *n2File)
	{
		if (!_scene)
		{
			_scene = new nGfxObject();
			_scene->SetResourceName(n2File);

			return _scene->Load();
		}
		else
			return false;
	}

	void NGUIManager::endScene()
	{
		if (_scene)
		{
			_scene->Unload();
			delete _scene;
		}

	}

	void NGUIManager::renderScene()
	{
		if (_scene)
			_scene->Render();
	}

	void NGUIManager::renderEntities()
	{
		//_entities->render();
		std::list<NGUIEntity*>::iterator it;
		it = _entities.begin();

		while (it != _entities.end())
		{
			(*it)->render();
			++it;
		}
	}

	void NGUIManager::cleanEntities()
	{
		// TODO: It must clean NGUIEntities
	}

} // namespace nebulaGUI*/
